<template>
  <div class="b2">
    <h2>A2组件</h2>
    <div>车:{{ car }}</div>
  </div>
</template>

<script setup>
import { ref, inject } from "vue";

const car = ref("");
const emitter = inject("emitter");
// on监听事件
emitter.on("sendCar1", (data) => {
  console.log("A2组件收到了A1的车:", data.value);
  car.value = data.value;
});
</script>

<style lang="scss" scoped>
.b2 {
  width: 400px;
  height: 400px;
  border: 2px solid skyblue;
  margin-top: 50px;
}
</style>